package com.teach;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Arrays;

public class Socke02 {
	public static void main(String[] args) {
		try {
			Socket clint = new Socket("192.168.31.112",1000);
			
			OutputStream out = clint.getOutputStream();
			System.out.println("连接上了服务器");
			out.write(new byte [] {65,6,7,8,1});
			out.flush();
			System.out.println("发送了一段字节数组");
			
			InputStream in = clint.getInputStream();
			byte [] bs = new byte[13];
			int len = in.read(bs);
			System.out.println("接收一段服务器端发送的字节数组"+len+"="+Arrays.toString(bs));
			
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
